<template>
    <div class="find">
        <myHeader title="发现" :find="true"></myHeader>
        <div class="dataInfo" v-if="isShow" v-for="(item, index) in travelList" :key="index">
        <div class="upPart">
            <div class="title">
                <p>{{ item.title }}</p>
            </div>
            <div class="tags">
                <span v-for="(i, v) in item.tags"><van-tag plain type="primary">{{ i.label }}</van-tag></span>
            </div>
            <div class="address"><van-icon name="guide-o" />
                <p>{{item.address}}</p>
            </div>
            <div class="time">
                <span>{{ item.time }}</span>
                <span><van-icon name="hot-o" />热度：{{ item.hot }}</span>
            </div>
        </div>
        <div class="imgPart">
            <!-- <img :src="'http://81.69.235.62:3000/' + item.imgs[0].url.slice(7)" alt=""> -->
            <!-- <img :src="item.imgs[0].url.replace('/public/','http://81.69.235.62:3000/')" alt=""> -->
        </div>
        <div class="content">
            <p>{{ item.content }}</p>
        </div>
        <hr>
        <div class="like">
            <div><van-icon name="good-job-o">1</van-icon></div>
            <div><van-icon name="edit">2</van-icon></div>
            <div><van-icon name="like-o">3</van-icon></div>
        </div>
    </div>

    <!-- <van-empty image="https://fastly.jsdelivr.net/npm/@vant/assets/cat.jpeg" description="登录后可同步购物车中商品"
        @click="gotoWhere('/find/sendDiray')"  /> -->
   
    </div>
</template>

<script setup>
import { useCommon } from "../../hooks/Common";
import { getAllTravelsAPI } from '../../api/search';
import { ref, reactive, onMounted } from "vue"

const isShow = ref(true)
const { gotoWhere } = useCommon()
const travelList = ref({})


const getAllTravels = async () => {
    try {
        let res = await getAllTravelsAPI();
        console.log(res.result);
        travelList.value = res.result
        console.log(travelList);
    } catch (err) {
        throw err.message
    }
}

onMounted(() => {
    getAllTravels()
})

</script>

<style lang="scss" scoped>
.find{
    width: 93%;
    padding: 0.15rem;
    .dataInfo {
        width: 100%;
        margin: auto;
        border: 1px solid Lightgray;
        padding: 0.1rem;
        border-radius: .20rem;
        margin-bottom: 0.3rem;

        .upPart {
            line-height: 1.5;

            .tags span {
                margin-right: 10px;
            }

            .address {
                font-size: .30rem;

                p {
                    display: inline-block;
                }

            }

            .time {
                display: flex;
                justify-content: space-between;
                font-size: .20rem;
                color: gray
            }
        }

        .imgPart {
            width: 100%;
            // padding: 10px;

            img {
                width: 100%;
                border-radius: .20rem;
            }

        }

        .content {
            line-height: 1.5;
            font-size: 0.3rem;
            color: gray;
        }

        .like {
            display: flex;
            justify-content: space-around;

            div {
                text-align: center;

            }
        }

    }

    .cancelView {
        width: 100%;

        p:nth-of-type(1) {
            text-align: center;
            font-size: 0.3rem;
            color: gray;
        }

        .history {
            margin-top:0.5rem ;
            padding: 10px;

            h1 {
                font-weight: 600;
                line-height: 2;
                border-bottom: 1px solid lightgray;
            }
            .cell {
                line-height: 2;
                border-bottom: 1px solid lightgray;

                 p{
                    text-align: left;
                    text-indent: 2;
                }
            }
        }
    }
}


</style>